'use strict';

/* Controllers */


function categoryCtrl($scope,$http) {
	$http.get('category').success(function(data) {
    $scope.categories = data;

  });
}
categoryCtrl.$inject = ['$scope','$http'];//inject required

function categoryUserCtrl($scope, $stateParams, $http) {
	nexus.categoryScope = $scope;
	 nexus.categoryScope.notJoined = true;
	$scope.joinCategory=function(){
		  if(nexus.headerScope.notLogin){
			 nexus.loginForm.show();
			//alert($location.path());
			nexus.loginForm.turl=function(){
				$location.path();
			};
			return;
		  }
		  
		  $http.post('category/' + $stateParams.id+'/addUser').success(function(data) {
			  nexus.categoryScope.notJoined = false;
		});
		
	};
	
  $http.get('category/' + $stateParams.id).success(function(data) {
    $scope.users = data;
  });
}
categoryUserCtrl.$inject = ['$scope','$stateParams','$http'];//inject required
